﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>Ord - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The Ord function returns the ordinal value (numeric character code) of the first character in the specified string." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>Ord</h1>

<p>返回指定字符串中首个字符的序号值(数字字符编码).</p>

<pre class="Syntax">Number := <span class="func">Ord</span>(String)</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>String</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>检索序号值的字符串.</p>
  </dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
<p>函数返回指定字符串中首个字符的序号值(数字化的字符编码). 如果字符串为空, 则返回 0. 如果字符串以 Unicode 补充字符开头, 本函数将返回对应的 Unicode 字符编码(一个介于 0x10000 到 0x10FFFF 之间的数字). 其他情况下返回的值介于 0 到 255(ANSI), 或 0 到 0xFFFF(Unicode). 有关详情, 请参阅 <a href="../Compat.htm#Format">Unicode vs ANSI</a>.</p>

<h2 id="Related">相关</h2>
<p><a href="Chr.htm">Chr</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a class="ex_number" href="#ExBasic"></a> 下面两个弹窗都显示 116, 因为只检测第一个字符.</p>
<pre>MsgBox Ord("t") 
MsgBox Ord("test")</pre>
</div>

</body>
</html>